package org.example.datascreen.controller;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.example.datascreen.eneity.DTO.CameraDTO;
import org.example.datascreen.eneity.DTO.DeviceDTO;
import org.example.datascreen.eneity.Result;
import org.example.datascreen.service.Impl.DeviceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/device")
public class DeviceController {
    @Autowired
    private DeviceServiceImpl deviceService;

    @RequiresAuthentication
    @RequestMapping("/getdevices")
    public Result<List<DeviceDTO>> getDevices(){
        List<DeviceDTO> devices = deviceService.getDeviceInfo();
        return Result.success(devices);
    }

    @RequiresAuthentication
    @RequestMapping("/getpictures")
    public Result<List<String>> getPictures(){
        List<String> pictures = deviceService.getPictures();
        System.out.println(pictures);
        return Result.success(pictures);
    }

    @RequiresAuthentication
    @RequestMapping("/getcamerainfo")
    public Result<CameraDTO> getCameraInfo(){
        CameraDTO camera = deviceService.getCameraInfo();
        return Result.success(camera);
    }
}
